<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>表单组合</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__STATIC__/extends/AmazeUI-2.7.2/css/amazeui.css">
    <link href="__STATIC__/css/base.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="__STATIC__/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATIC__/layuiadmin/style/admin.css" media="all">

    <script src="__STATIC__/js/jquery-1.8.3.min.js"></script>
    <script src="__STATIC__/extends/AmazeUI-2.7.2/js/amazeui.min.js"></script>

    <link rel="stylesheet" href="__STATIC__/css/seller.css">
    <link rel="stylesheet" href="__STATIC__/css/seller_goods.css">
    <script src="__STATIC__/js/common1.js"></script>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">{$type}</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form action="" method="post"  class="layui-form">

                <div class="layui-form-item">
                    <label class="layui-form-label">角色组名：</label>
                    <div class="layui-input-block formControls">
                        <input type="text" lay-verify="title" autocomplete="off" placeholder="请输入角色组名"
                               name="title" datatype="*" nullmsg="角色组名不能为空！" ajaxurl="{:url('AdminGroup/ajaxTitle')}" class="layui-input">
                        <span class="Validform_checktip"></span>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态：</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="启用" checked="">
                        <input type="radio" name="status" value="2" title="禁用">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">排序：</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" value="50" placeholder="排序"  lay-verify="title" autocomplete="off"  class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即提交</button>
                            <a href="{:url('Admin/index')}" class="layui-btn layui-btn-primary">返回</a>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="__STATIC__/extends/layui2.4.5/layui.all.js "></script>
<script src="__STATIC__/extends/Validform/5.3.2/Validform.min.js "></script>
<script src="__STATIC__/extends/js/jquery-ui.js"></script>
<script src="__STATIC__/js/seller_goods.js"></script>
<script src="__STATIC__/js/seller_goods_sku.js"></script>

<script type="text/javascript">
    $(function() {
        //表单验证
        $("form").Validform({
            tiptype:function(msg,o,cssctl){
                if(!o.obj.is("form")){
                    //默认表单
                    var objtip=o.obj.parents(".formControls").find(".Validform_checktip");
                    cssctl(objtip,o.type);
                    objtip.text(msg);
                }
            },
            showAllError:true
        })

    });


</script>

<script src="__STATIC__/layuiadmin/layui/layui.js"></script>

<script>
    layui.config({
        base: '__STATIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form;

        form.render('checkbox');
        form.render(null, 'component-form-group');

        laydate.render({
            elem: '#LAY-component-form-group-date'
        });
        return false;
    });


    layui.use(['form', 'upload'], function () {
        var upload = layui.upload;
        upload_img('image');
        function upload_img (id) {
            //选完文件后自动上传
            upload.render({
                elem: '#'+id,
                url: "{:url('UpFiles/upload')}",
                auto: true,
                accept: 'file', //普通文件
                data :{type:id,name:'file'},
                before: function (obj) {
                    var img_url = $('input[name='+id+']').val();
                    // 删除老数据
                    if (img_url != '') {
                        $.ajax({
                            url: "{:url('UpFiles/delImg')}",
                            type: 'POST',
                            data: {
                                img_url: img_url
                            },
                        });
                    }
                    //本地本地预览示例
                    obj.preview(function(index,file,result){
                        $("#"+id+"_thumb").attr('src',result).show();
                    });
                },
                done: function (res) {
                    //上传完毕回调
                    if (res.code > 0) {
                        return layer.msg('上传失败');
                    } else {
                        $("#"+id+"_thumb").attr('src',res.data.src).show();
                        $('input[name='+id+']').val(res.data.src);
                    }
                }
            });
        }
    });


</script>
</body>
</html>
